<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增发票')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <style>
		.file-preview {
		    padding: 0;
		    margin-bottom: 0;
		    border-radius: 0;
		    border: none;
		}
		
		.krajee-default.file-preview-frame {
		    margin-right: 20px;
		    padding: 0;
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default.file-preview-frame:not(.file-preview-error):hover {
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default .file-footer-caption {
			margin-bottom: 0;
		}
		
		.krajee-default.file-preview-frame .file-thumbnail-footer {
		    height: auto;
		}
		
		.krajee-default .file-caption-info {
			width: auto;
		}
		
		.kv-upload-progress .progress {
			margin-top: 0;
		}
		
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-size-info,
		.krajee-default .file-upload-indicator,
		.file-input .kv-file-upload,
		.file-input .kv-file-zoom {
			display: none;
		}
		
		.file-input .kv-file-remove {
			position: absolute;
			top: 3px;
			right: -15px;
			height: 14px;
			padding: 0;
			margin: 0;
			border: none;
			background: none;
		}
		
		.file-input .kv-file-remove:active, 
		.file-input .kv-file-remove:focus {
			background: none;
			outline: none;
			box-shadow: none;
		}
		
		.file-input .kv-file-remove .glyphicon-trash {
			color: red;
		}
	</style>
    <style type="text/css">
        table label.error{position: inherit;}select + label.error{z-index:1;right:40px;}
    </style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-fkfp-add">
        	<input name="gcProjectid" class="form-control" type="hidden" th:value="${gcProjectid}">
            <input name="projectId" class="form-control" type="hidden" th:value="${projectId}">
            <input name="fkId" class="form-control" type="hidden" th:value="${fkId}">
            <input name="xmtype" class="form-control" type="hidden" th:value="${xmtype}">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">项目编号：</label>
                <div class="col-sm-8">
                    <input name="projectNo" class="form-control" type="text" autoComplete="off"  th:value="${projectNo}" readonly="readonly" >
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input name="xmmc" class="form-control" type="text" autoComplete="off"  th:value="${xmmc}" readonly="readonly" >
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">单位名称：</label>
                <div class="col-sm-8">
                	<input name="ckdw" class="form-control" type="text" autoComplete="off" th:value="${supplyName1}" readonly="readonly">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">发票编号(后6位)：</label>
                <div class="col-sm-8">
                    <input name="fpNo" class="form-control" type="text" maxlength="6" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group"> 
            	<label class="col-sm-3 control-label is-required">开票日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="fpriq" class="form-control" required placeholder="yyyy-MM-dd" type="text" autoComplete="off" th:value="${riq}">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">发票类型：</label>
                <div class="col-sm-8">
                	<select  name="fpType" class="form-control" required>
						<option th:value="专用发票">专用发票</option>
			            <option th:value="普通发票">普通发票</option>
			            <option th:value="其他选项">其他选项</option>
					</select>
                </div>
            </div>
            
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">发票金额：</label>
                <div class="col-sm-8">
                    <input name="fpjine" class="form-control" type="text" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group"> 
	            <label class="col-sm-3 control-label is-required">发票税率：</label>
	            <div class="col-sm-8">
		            <select name="fpsl" class="form-control" required>
			            <option th:value="9">9%</option>
		                <option th:value="6">6%</option>
		                <option th:value="3">3%</option>
		                <option th:value="1">1%</option>
		                <option th:value="0">0%</option>
		                <option th:value="11">11%</option>
		                <option th:value="13">13%</option>
		         	</select>
	            </div>
	        </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">可抵扣税额：</label>
                <div class="col-sm-8">
                    <input name="kdkse" class="form-control" type="text" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group">
	            <label class="col-sm-3 control-label is-required">上传进项发票（PDF）：</label>
	            <div class="col-sm-8">
	            	<input id="fap" name="fap" type="hidden">
	            	<div class="file-loading">
		            	<input id="multipleFile" name="files" type="file" multiple>
		        	</div>
	            </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="memo" class="form-control"></textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <script th:src="@{/js/jquery.tmpl.js}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/fkfp"
        $("#form-fkfp-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
            	if($("#fap").val()===""){
            		$.modal.alertWarning("请上传发票文件！");
            		return;
            	}
            	var form = document.getElementById("form-fkfp-add");
                var file = new FormData(form);
                $.ajax({
                    url: "/gcgl/fkfp/add",
                    type: "POST",
                    processData:false,
                    contentType:false,
                    //重要部分，data的传的是整个表单，不用大括号包裹；不用自定义变量名
                    data:file,
                    success: function (data) {
                    	$.modal.close();
                    	refreshTab();
                    },
                    error: function (data) {
                    	$.modal.close();
                    	refreshTab();
                    }
                })
            }
        }
        
        $("input[name='fpriq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        
        $(document).ready(function () {
		       // 多图上传
		       $("#multipleFile").fileinput({
		           uploadUrl: "/gcgl/sbclht/uploads",
		           uploadAsync: false,
		           showClose: false,
		           showCancel: false,
		           dropZoneEnabled: false,
		           buttonLabelClass: ''
		       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
		       	var rsp = data.response;
//		       	   log.info("return urls：" + rsp.urls)
		           log.info("reutrn fileNames：" + rsp.fileNames)
//		           log.info("reutrn newFileNames：" + rsp.newFileNames)
//		           log.info("return originalFilenames：" + rsp.originalFilenames)
				   $("#fap").val(rsp.fileNames);
		       }).on('fileremoved', function (event, id, index) {
		           $("input[name='" + event.currentTarget.id + "']").val('')
		       })
		 });
    </script>
</body>
</html>